//
//  GradientView.m
//  ShadowedTableView
//
//  Created by Matt Gallagher on 2009/08/21.
//  Copyright 2009 Matt Gallagher. All rights reserved.
//

#import "GradientView.h"
#import <QuartzCore/QuartzCore.h>

@implementation GradientView

//
// layerClass
//
// returns a CAGradientLayer class as the default layer class for this view
//
+ (Class)layerClass
{
	return [CAGradientLayer class];
}

//
// setupGradientLayer
//
// Construct the gradient for either construction method
//
- (void)changeColor:(BOOL)isTitle {
	CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
	// 0xRRGGBBAA
	int color1 = (!isTitle) ? 0xffffffff : 0xb6bdc3ff;
	int color2 = (!isTitle) ? 0xe6e6e6ff : 0x8fa1abff;
	UIColor *c1 = HEXCOLOR(color1);
	UIColor *c2 = HEXCOLOR(color2);
	gradientLayer.colors =
		[NSArray arrayWithObjects:
			(id)c1.CGColor,
			(id)c2.CGColor,
		nil];
}

//
// initWithFrame:
//
// Initialise the view.
//
- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
	self.backgroundColor = [UIColor clearColor];
    return self;
}

@end
